<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <link rel="stylesheet" type="text/css"
            href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
        <link rel="stylesheet" type="text/css"
            href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
        <link rel="Stylesheet" type="text/css"
            href="<c:url value="/static/css/jquery.ui.css"/>" />
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
        <script type="text/javascript" src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>   
        <script type="text/javascript"
            src="<c:url value="/static/js/common.js"/>"></script>       
        <script type="text/javascript" src="<c:url value="/static/js/Loading.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/js/showMsg.js"/>"></script>
        <script type="text/javascript"
            src="<c:url value="/static/listBox/jquery.clever.listbox.js"/>"></script>
        
        <script>
            var dataLeft;
			$(document).ready(function() {
				initHtmlProperties();
		        document.getElementById('custIdDeal').value = 0;
		        document.getElementById('zzy').style.display = 'none';
		        
		        document.getElementById('custIdAll').value = '';
                document.getElementById('zzy2').style.display = 'none';
                
                document.getElementById('trDis').style.display = 'none';
			});
			  
		    
			function excel(){
				$('#AddFoodForm').form('submit',
		 				{
		 					url:'<c:url value='/supplier/exportSupperExcel.do'/>', //查询提交路径
		 					onSubmit:function()//提交按钮相应函数
		 					{
		 						if($('#valueType').combobox('getValue') ==2){
		 							if(document.getElementById('custIdDeal').value == 0){
	                                    alert("请选择默认价格的客户！");
	                                    return false;
	                                }
		 						}
		 						
		 						var Allwidth = '100%';
		 		                var Allheight = '100%';
		 		                Loading.Show({width:Allwidth,height:Allheight});
		 		                setTimeout(function(){
		 		                    Loading.Hide();
		 		                },3000)
		 		                //校验
                                if($('#orderDate').datebox('getValue') ==''){
                                    $.messager.alert('提示','订单日期没有填写！','info');
                                    closeShow();
                                }
		 						return $('#AddFoodForm').form('validate');
		 					},
		 					success:function(data){
		                        data = eval( "("+data+")" );
		                        if(data.success){
		                            $.messager.alert("提示", "提交成功！", 'info');
		                        }else{
		                            var message = "";
		                            if(data.msg == "msg002"){
		                                message = "所选择日期的材料订单已经下单完成，如需重新选择请删除已有订单。";
		                            }else if(data.msg == "msg001"){
		                                message = "选择材料的时间已过，请联系采购部。";
		                            }else {
		                            	message =data.msg;
		                            }
		                            $.messager.alert("提示", message, 'warning');
		                        }
		                    },
		                    error:function(){
		                        $.messager.alert("错误", "系统错误，请联系管理员！", 'error');
		                        return;
		                    }
		 				});
				
				
			}
			function closeShow(){
				Loading.Hide();
			}
			
			
			
			function initHtmlProperties() {
				$('#valueType').combobox({   
                    data:[{"valueType":"1","valueTypename":"进货价格"},{"valueType":"2","valueTypename":"最后一次送货价格"}],   
                    editable:true, //不可编辑状态  
                    cache: false,  
                    panelHeight: '150',  
                    valueField:'valueType',     
                    textField:'valueTypename',
                    required:true,
                    onSelect: function(rec){    
                        if(rec.valueType==2){
                            document.getElementById('trDis').style.display = '';
                        };   
                        if(rec.valueType==1){
                            document.getElementById('trDis').style.display = 'none';
                        };
                    }
                }); 
				$('#orderBy').combobox({   
                    data:[{"orderBy":"e.describ","orderByName":"材料种类"},{"orderBy":"a.ord_mater_id","orderByName":"材料id"}],   
                    editable:true, //不可编辑状态  
                    cache: false,  
                    panelHeight: '150',  
                    valueField:'orderBy',     
                    textField:'orderByName',
                    required:true,
                    value:'a.ord_mater_id'
                }); 
				
		        $("#custName").textbox({
		            buttonText : '选择',
		            iconAlign : 'left',
		            editable : false,
		            value : "无",
		            multiline : true,
		            height : '25px',
		            onClickButton : function() {
		            	if($('#orderDate').datebox('getValue') ==''){
                            $.messager.alert('提示','请先填写导出日期!','info');
                            return false;
                        }
		                initDateLeft($('#orderDate').datebox('getValue'));
		                showMsgLeft();
		                ShowDiv();

		                var left = $('#left').listbox();
		                var items = left.getDatas();
		                left.removeRange(items);

		                /* var right = $('#right').listbox();
		                var itemsr = right.getDatas();
		                right.removeRange(itemsr);
		                 */
		                $('#left').listbox().reload({
		                    data : dataLeft,
		                    ajaxsettings : {
		                        data : {
		                            id : 'a'
		                        }
		                    }
		                });
		            }
		        });
		        
		        $("#custNameAll").textbox({
                    buttonText : '选择',
                    iconAlign : 'left',
                    editable : false,
                    value : "全部",
                    multiline : true,
                    height : '65px',
                    width : '300px',
                    onClickButton : function() {
                        if($('#orderDate').datebox('getValue') ==''){
                            $.messager.alert('提示','请先填写导出日期!','info');
                            return false;
                        }
                        initDateLeft($('#orderDate').datebox('getValue'));
                        showMsgLeft2();
                        ShowDiv2();
                        var left = $('#left2').listbox();
                        var items = left.getDatas();
                        left.removeRange(items);

                        /* var right = $('#right').listbox();
                        var itemsr = right.getDatas();
                        right.removeRange(itemsr);
                         */
                        $('#left2').listbox().reload({
                            data : dataLeft,
                            ajaxsettings : {
                                data : {
                                    id : 'a'
                                }
                            }
                        });
                    }
                });
		    }
		    //选择客户
		    function ShowDiv() {
		        var Allwidth = '100%';
		        var Allheight = '100%';
		        document.getElementById('zzy').style.display = '';
		        Loading.Show({
		            width : Allwidth,
		            height : Allheight
		        });

		    }
		    //选择客户
            function ShowDiv2() {
                var Allwidth = '100%';
                var Allheight = '100%';
                document.getElementById('zzy2').style.display = '';
                Loading.Show({
                    width : Allwidth,
                    height : Allheight
                });

            }
		    //获取data 数据
		    function initDateLeft(orderDate) {
		        $.ajax({
		            async : false,
		            url : "<c:url value='/user/userTestValueForSuppOrder.do'/>"+"?orderDate="+orderDate,
		            type : "post",
		            success : function(data) {
		                if (typeof (data) == 'string' && data != '') {
		                    data = JSON.parse(data);
		                }
		                dataLeft = data.stringJson;
		                if (typeof (dataLeft) == 'string' && dataLeft != '') {
		                    dataLeft = JSON.parse(dataLeft);
		                }
		            }
		        });
		    }
		    //初始化showMsg
		    function showMsgLeft() {
		        $('#left').listbox({
		            data : dataLeft,
		            height : 300,
		            width : 200,
		            dndscope : 'demo',
		            dnd : false,
		            multiselect : true,
		            selectchange : function(data) {
		                if (data && data.length > 0) {
		                    $('#btnRight').attr('disabled', false);
		                } else {
		                    $('#btnRight').attr('disabled', true);
		                }
		            }
		        });
		        var data = [ {
		            value : 10,
		            text : 'think8848'
		        }, {
		            value : 20,
		            text : 'aCloud'
		        }, {
		            value : 21,
		            text : 'aaaaa'
		        }, {
		            value : 36,
		            text : 'qqqqq'
		        } ];
		        $('#right').listbox({
		            //data: data,
		            height : 300,
		            width : 200,
		            dndscope : 'demo',
		            dnd : true,
		            multiselect : true
		        });
		        $('#btnRightAll').click(function() {
		            var left = $('#left').listbox();
		            var items = left.getDatas();
		            left.clear();
		            $('#right').listbox().addRange(items);
		        });
		        $('#btnLeftAll').click(function() {
		            var right = $('#right').listbox();
		            var items = right.getDatas();
		            right.clear();
		            $('#left').listbox().addRange(items);
		        });
		        $('#btnRight').click(function() {
		            var left = $('#left').listbox();
		            var items = left.getSelected();
		            left.removeRange(items);
		            $('#right').listbox().addRange(items);
		        });
		        $('#btnLeft').click(function() {
		            var right = $('#right').listbox();
		            var items = right.getSelected();
		            right.removeRange(items);
		            $('#left').listbox().addRange(items);
		        });
		        $('#btnRemove').click(function() {
		            $('#right').listbox().removeRange([ {
		                value : 2
		            }, {
		                value : 26
		            } ]);
		        });
		        $('#btnSelect').click(function() {
		            var selected = $('#right').listbox().getSelected();
		            var msg = 'Selected count is: ' + selected.length;
		            if (selected.length > 0) {
		                msg += ', The first item text is: ' + selected[0].text;
		            }
		            msg += '.';
		            alert(msg);
		        });
		        $('#btnGetItems').click(function() {
		            var selected = $('#right').listbox('getDatas');
		            alert('Items count is: ' + selected.length);
		        });
		        $('#btnSetSelection').click(function() {
		            $('#left').listbox('setSelection', 1);
		        });
		        $('#select').click(function() {
		            Loading.Hide();
		            document.getElementById('zzy').style.display = 'none';

		            var right = $('#right').listbox();
		            var items = right.getDatas();
		            var userNames = '';
		            var userIds = '';
		            if (items.length > 1) {
		            	alert("只能选取一位客户");
		            	return false;
		            }
		            
		            if (items.length > 0) {
		                for ( var e in items) {
		                    userNames = userNames + items[e].text + ',';
		                    userIds = userIds + items[e].value + ',';
		                }
		                userNames = userNames.substring(0, userNames.length - 1);
		                userIds = userIds.substring(0, userIds.length - 1);
		            }
		            if (userNames != '' && userIds != '') {
		                $('#custName').textbox('setValue', userNames);
		                document.getElementById('custIdDeal').value = userIds;
		            } else {
		                $('#custName').textbox('setValue', '无');
		                document.getElementById('custIdDeal').value = 0;
		            }
		        });
		        $('#noselect').click(function() {
		            Loading.Hide();
		            document.getElementById('zzy').style.display = 'none';
		        });
		    }
		    
		  //初始化showMsg2
            function showMsgLeft2() {
                $('#left2').listbox({
                    data : dataLeft,
                    height : 300,
                    width : 200,
                    dndscope : 'demo',
                    dnd : false,
                    multiselect : true,
                    selectchange : function(data) {
                        if (data && data.length > 0) {
                            $('#btnRight2').attr('disabled', false);
                        } else {
                            $('#btnRight2').attr('disabled', true);
                        }
                    }
                });
                $('#right2').listbox({
                    //data: data,
                    height : 300,
                    width : 200,
                    dndscope : 'demo',
                    dnd : true,
                    multiselect : true
                });
                $('#btnRightAll2').click(function() {
                    var left = $('#left2').listbox();
                    var items = left.getDatas();
                    left.clear();
                    $('#right2').listbox().addRange(items);
                });
                $('#btnLeftAll2').click(function() {
                    var right = $('#right2').listbox();
                    var items = right.getDatas();
                    right.clear();
                    $('#left2').listbox().addRange(items);
                });
                $('#btnRight2').click(function() {
                    var left = $('#left2').listbox();
                    var items = left.getSelected();
                    left.removeRange(items);
                    $('#right2').listbox().addRange(items);
                });
                $('#btnLeft2').click(function() {
                    var right = $('#right2').listbox();
                    var items = right.getSelected();
                    right.removeRange(items);
                    $('#left2').listbox().addRange(items);
                });
                $('#btnRemove2').click(function() {
                    $('#right2').listbox().removeRange([ {
                        value : 2
                    }, {
                        value : 26
                    } ]);
                });
                $('#btnSelect2').click(function() {
                    var selected = $('#right2').listbox().getSelected();
                    var msg = 'Selected count is: ' + selected.length;
                    if (selected.length > 0) {
                        msg += ', The first item text is: ' + selected[0].text;
                    }
                    msg += '.';
                    alert(msg);
                });
                $('#btnGetItems2').click(function() {
                    var selected = $('#right2').listbox('getDatas');
                    alert('Items count is: ' + selected.length);
                });
                $('#btnSetSelection2').click(function() {
                    $('#left2').listbox('setSelection', 1);
                });
                $('#select2').click(function() {
                    Loading.Hide();
                    document.getElementById('zzy2').style.display = 'none';

                    var right = $('#right2').listbox();
                    var items = right.getDatas();
                    var userNames = '';
                    var userIds = '';
                   
                    
                    if (items.length > 0) {
                        for ( var e in items) {
                            userNames = userNames + items[e].text + ',';
                            userIds = userIds + items[e].value + ',';
                        }
                        userNames = userNames.substring(0, userNames.length - 1);
                        userIds = userIds.substring(0, userIds.length - 1);
                    }
                    if (userNames != '' && userIds != '') {
                        $('#custNameAll').textbox('setValue', userNames);
                        document.getElementById('custIdAll').value = userIds;
                    } else {
                        $('#custNameAll').textbox('setValue', '全部');
                        document.getElementById('custIdAll').value = '';
                    }
                });
                $('#noselect2').click(function() {
                    Loading.Hide();
                    document.getElementById('zzy2').style.display = 'none';
                });
            }

		    function searchInfoForShowCust() {
		        $('#searchFormForShowCust').form('submit', {
		            url : '<c:url value='/user/checkCustlook.do'/>', //查询提交路径
		            onSubmit : function()//提交按钮相应函数
		            {
		                return $('#searchFormForShowCust').form('validate');
		            },
		            success : function(data) {
		                data = eval("(" + data + ")");
		                /* var left = $('#left').listbox();
		                var items = left.getDatas();
		                left.removeRange(items); */

		                /* var right = $('#right').listbox();
		                var itemsr = right.getDatas();
		                right.removeRange(itemsr); */
		                $('#left').listbox().reload({
		                    data : data,
		                    ajaxsettings : {
		                        data : {
		                            id : 'a'
		                        }
		                    }
		                });
		            },
		            error : function() {
		                $.messager.alert("错误", "系统错误，请联系管理员！", 'error');
		                return;
		            }
		        });
		    }
		</script>
			</head>
			<body>
			<table width="98%">
			<tr><td>
				<form id="AddFoodForm" name="AddFoodForm" method="post">
				<div style="height: auto; width:1180px;background: #fafafa; padding: 5px;" class="easyui-panel" title="送货报表导出" iconCls="icon-add" collapsible="true" minimizable="false" maximizable="false" closable="false">
			    <table cellpadding="5">
			      <tr>
                  	<td>日期</td>
                    <td>
 			            <input class="easyui-datebox" name="orderDate" id="orderDate" editable="false" data-options="required:true"/> 
 			        </td>
                  </tr>
                  <tr>
                      <td colspan="2">选择导出的客户（默认为全部店）</td>
                      <td><input style="word-wrap: break-word; word-break: break-all;" id="custNameAll" name="custNameAll"></input></td>
                      <td><input class="easyui-validatebox" editable="false"
                                id="custIdAll" name="custIdAll" type="hidden"></input></td>
                  </tr>
                  <tr>
                      <td colspan="2">默认价格类型：</td>
                      <td><input class="easyui-combobox" id="valueType" editable="false" name="valueType"></input></td>
                  </tr>
                  <tr id='trDis'>
                      <td colspan="2">选择按照哪个客户设置默认价格</td>
                      <td><input style="word-wrap: break-word; word-break: break-all;" id="custName" name="custName"></input></td>
                      <td><input class="easyui-validatebox" editable="false"
                                id="custIdDeal" name="custIdDeal" type="hidden"></input></td>
                  </tr>
                  
                  <tr>
                      <td colspan="2">报表排序：</td>
                      <td><input class="easyui-combobox" id="orderBy" editable="false" name="orderBy"></input></td>
                  </tr>
                  <tr>
                      <td>
                        <a href="#" class="easyui-linkbutton" onclick="excel();">导出</a>
                      </td>
                  </tr>
				        <input class="easyui-validatebox" type="hidden" name="idList"  />
				        <input class="easyui-validatebox" type="hidden" name="excelList"  />
				        <input class="easyui-validatebox" type="hidden" name="footList"  />
				        <input class="easyui-validatebox" type="hidden" name="supId" value="0"  />
				        
                </table>
                </div>
                </form>
            </td></tr>
            </table>
			<table width="98%">
			<tr>
		</table>
	</body>
	
	<div
        style='position: absolute; left: 40px; top: 40px; z-index: 101; background-color: #FFFFFF; border-radius: 10px; width: 550px;'
        id="zzy">
        <table align="center">
            <tr>
                <td colspan="3">
                    <form id="searchFormForShowCust" name="searchFormForShowCust"
                        method="post" accept-charset="UTF-8">
                        <div
                            style="height: auto; width: 470px; background: #fafafa; padding: 5px;"
                            class="easyui-panel" title="查询" iconCls="icon-search"
                            collapsible="true" minimizable="false" maximizable="false"
                            closable="false">
                            <table>
                                <tr>
                                    <td>省:</td>
                                    <td><input class="easyui-combobox" name="provinceShow"
                                        id="provinceShow" required="true" /></td>
                                    <td>市:</td>
                                    <td><input class="easyui-combobox" name="cityShow"
                                        id="cityShow" required="true" /></td>
                                </tr>
                                <tr>
                                    <td>区:</td>
                                    <td><input class="easyui-combobox" name="countryShow"
                                        id="countryShow" required="true" /></td>
                                    <td colspan="2"><a href="#" class="easyui-linkbutton"
                                        data-options="iconCls:'icon-search'" style="width: 60px"
                                        onclick="searchInfoForShowCust()">查询</a></td>
                                </tr>
                            </table>
                        </div>
                    </form>
                </td>
            </tr>
            <tr>
                <td>
                    <ul id="left">
                    </ul>
                </td>
                <td><input type="button" value="&gt;&gt;" id="btnRightAll"
                    style="width: 50px;" /><br /> <input type="button" value="&gt;"
                    id="btnRight" style="width: 50px;" /><br /> <input type="button"
                    value="&lt;" id="btnLeft" style="width: 50px;" /><br /> <input
                    type="button" value="&lt;&lt;" id="btnLeftAll" style="width: 50px;" />
                </td>
                <td>
                    <ul id="right">
                    </ul>
                </td>
            </tr>
        </table>
        <table align="center">
            <tr>
                <!--  
                <td><input type="button" value="Add Item" id="btnAdd" /></td>
                <td><input type="button" value="Remove Item" id="btnRemove" /></td>
                <td><input type="button" value="Get Select" id="btnSelect" /></td>
                <td><input type="button" value="Get Items" id="btnGetItems" /></td>
                <td><input type="button" value="SetSelection (value equal to '1')" id="btnSetSelection" /></td>
                <td><input type="button" value="Reload" id="btnReload" /></td>
                -->
                <td><input type="button" value="取消" id="noselect" /></td>
                <td width="200px"></td>
                <td><input type="button" value="选择" id="select" /></td>

            </tr>
        </table>
    </div>
    
    <div
        style='position: absolute; left: 40px; top: 40px; z-index: 101; background-color: #FFFFFF; border-radius: 10px; width: 550px;'
        id="zzy2">
        <table align="center">
            <tr>
                <td colspan="3">
                    <form id="searchFormForShowCust" name="searchFormForShowCust"
                        method="post" accept-charset="UTF-8">
                        <div
                            style="height: auto; width: 470px; background: #fafafa; padding: 5px;"
                            class="easyui-panel" title="查询" iconCls="icon-search"
                            collapsible="true" minimizable="false" maximizable="false"
                            closable="false">
                            <table>
                                <tr>
                                    <td>省:</td>
                                    <td><input class="easyui-combobox" name="provinceShow"
                                        id="provinceShow" required="true" /></td>
                                    <td>市:</td>
                                    <td><input class="easyui-combobox" name="cityShow"
                                        id="cityShow" required="true" /></td>
                                </tr>
                                <tr>
                                    <td>区:</td>
                                    <td><input class="easyui-combobox" name="countryShow"
                                        id="countryShow" required="true" /></td>
                                    <td colspan="2"><a href="#" class="easyui-linkbutton"
                                        data-options="iconCls:'icon-search'" style="width: 60px"
                                        onclick="searchInfoForShowCust()">查询</a></td>
                                </tr>
                            </table>
                        </div>
                    </form>
                </td>
            </tr>
            <tr>
                <td>
                    <ul id="left2">
                    </ul>
                </td>
                <td><input type="button" value="&gt;&gt;" id="btnRightAll2"style="width: 50px;" />
                    <br /> 
                    <input type="button" value="&gt;" id="btnRight2" style="width: 50px;" />
                    <br /> 
                    <input type="button" value="&lt;" id="btnLeft2" style="width: 50px;" />
                    <br />
                    <input type="button" value="&lt;&lt;" id="btnLeftAll2" style="width: 50px;" />
                </td>
                <td>
                    <ul id="right2">
                    </ul>
                </td>
            </tr>
        </table>
        <table align="center">
            <tr>
                <!--  
                <td><input type="button" value="Add Item" id="btnAdd" /></td>
                <td><input type="button" value="Remove Item" id="btnRemove" /></td>
                <td><input type="button" value="Get Select" id="btnSelect" /></td>
                <td><input type="button" value="Get Items" id="btnGetItems" /></td>
                <td><input type="button" value="SetSelection (value equal to '1')" id="btnSetSelection" /></td>
                <td><input type="button" value="Reload" id="btnReload" /></td>
                -->
                <td><input type="button" value="取消" id="noselect2" /></td>
                <td width="200px"></td>
                <td><input type="button" value="选择" id="select2" /></td>

            </tr>
        </table>
    </div>
</html>